package com.uzai.console.web.alipay;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.dto.alipaydetail.AlipayDetailCreateDto;
import com.uzai.console.enums.AlipayTypeEnum;
import com.uzai.console.service.cdkeys.AlipayForCdkeysService;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 代理平台充值
 *
 * @author cen
 * @date 2022-7-12 15:56:11
 */
@Api(value = "代理平台支付宝充值及查询", tags = "交易明细|代理平台支付宝充值及查询")
@ApiSort(117)
@RestController
public class AlipayForCdkeyController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(AlipayForCdkeyController.class);


    @Autowired
    private AlipayForCdkeysService alipayForCdkeysService;

    @ApiOperation(value = "支付宝生产二维码支付", notes = "支付宝生产二维码支付", response = String.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/alipay/cdkey/findAlipayDetailList")
    public Object findAlipayDetailList(@RequestBody AlipayDetailCreateDto alipayDetailCreateDto) {
        alipayDetailCreateDto.setSubject(AlipayTypeEnum.CDKEY_AGENT_RECHARGE.getDesc());
        return alipayForCdkeysService.createAlipayDetail(alipayDetailCreateDto);
    }

//    @ApiOperation(value = "查询支付宝支付页面", notes = "查询支付宝支付页面", response = AlipayDetailCreateVo.class)
//    @ApiOperationSupport(order = 2)
//    @PostMapping("/alipay/findAlipayUrl")
//    public Object findAlipayUrl(@RequestBody AlipayDetailAlipayUrlDao alipayDetailAlipayUrlDao){
//        return alipayForCdkeysService.findAlipayUrl(alipayDetailAlipayUrlDao.getId());
//    }

    @ApiOperation(value = "根据tradeNo查询订单信息 , 并更改订单状态", notes = "根据tradeNo查询订单信息, 并更改订单状态", response = AlipayDetailCreateDto.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/alipay/cdkey/queryTradeNo")
    public Object findOrderStatus(@RequestBody AlipayDetailCreateDto detailCreateDto) {
        return alipayForCdkeysService.alipayTradeQuery(detailCreateDto.getOutTradeNo());
    }


}
